package com.dog.basics.netty.consts;


import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.AttributeKey;

/**
 * DTU常量
 */
public class Const {

	/**
	 * 固定帧头
	 */
	public static final String headDefaultSrt = "ASXC";

	/**
	 * 接收报文最短长度（无数据内容无校验）
	 */
	public static final int acceptMinMsgLength = 9;

	/**
	 * 接收报文最大长度
	 */
	public static final int acceptMaxMsgLength = 1024;
	/**
	 * 报文最短长度
	 */
	public static final int sendMinMsgLength = 19;

	public static final int nextFieldLength = 1;


	/**
	 * 帧头字段长度
	 */
	public static final int headFieldLength = 4;

	/**
	 * 消息长度字段的长度
	 * 整个帧的长度
	 */
	public static final int msgFieldLength = 4;

	/**
	 * 过滤几位数 - 使用与 LengthFieldBasedFrameDecoder
	 */
	public static final int lengthAdjustment = -8;

	/**
	 * 版地址
	 */
	public static final int versionAddressLength = 1;

	/**
	 * 指令长度
	 */
	public static final int instructionsLength = 1;

	/**
	 * 帧尾字段长度
	 */
	public static final int tailFieldLength = 1;


	/**
	 * 最大能忍受多长时间未收到心跳
	 */
	public static final int maxIdleTime = 200;

	/**
	 * channel对应的连接
	 */
	public static final AttributeKey<NioSocketChannel> connection = AttributeKey.valueOf("connection");


}
